package com.sanqi.work.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sanqi.common.annotation.Log;
import com.sanqi.common.core.controller.BaseController;
import com.sanqi.common.core.domain.AjaxResult;
import com.sanqi.common.enums.BusinessType;
import com.sanqi.work.domain.WorkUserDate;
import com.sanqi.work.service.IWorkUserDateService;
import com.sanqi.common.utils.poi.ExcelUtil;
import com.sanqi.common.core.page.TableDataInfo;

/**
 * 员工每日工作安排Controller
 * 
 * @author duany
 * @date 2025-09-24
 */
@RestController
@RequestMapping("/work/userdate")
public class WorkUserDateController extends BaseController
{
    @Autowired
    private IWorkUserDateService workUserDateService;

    /**
     * 查询员工每日工作安排列表
     */
    @PreAuthorize("@ss.hasPermi('work:userdate:list')")
    @GetMapping("/list")
    public TableDataInfo list(WorkUserDate workUserDate)
    {
        startPage();
        List<WorkUserDate> list = workUserDateService.selectWorkUserDateList(workUserDate);
        return getDataTable(list);
    }

    /**
     * 导出员工每日工作安排列表
     */
    @PreAuthorize("@ss.hasPermi('work:userdate:export')")
    @Log(title = "员工每日工作安排", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WorkUserDate workUserDate)
    {
        List<WorkUserDate> list = workUserDateService.selectWorkUserDateList(workUserDate);
        ExcelUtil<WorkUserDate> util = new ExcelUtil<WorkUserDate>(WorkUserDate.class);
        util.exportExcel(response, list, "员工每日工作安排数据");
    }

    /**
     * 获取员工每日工作安排详细信息
     */
    @PreAuthorize("@ss.hasPermi('work:userdate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(workUserDateService.selectWorkUserDateById(id));
    }

    /**
     * 新增员工每日工作安排
     */
    @PreAuthorize("@ss.hasPermi('work:userdate:add')")
    @Log(title = "员工每日工作安排", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WorkUserDate workUserDate)
    {
        return toAjax(workUserDateService.insertWorkUserDate(workUserDate));
    }

    /**
     * 修改员工每日工作安排
     */
    @PreAuthorize("@ss.hasPermi('work:userdate:edit')")
    @Log(title = "员工每日工作安排", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WorkUserDate workUserDate)
    {
        return toAjax(workUserDateService.updateWorkUserDate(workUserDate));
    }

    /**
     * 删除员工每日工作安排
     */
    @PreAuthorize("@ss.hasPermi('work:userdate:remove')")
    @Log(title = "员工每日工作安排", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(workUserDateService.deleteWorkUserDateByIds(ids));
    }
}
